package www.dianbaozu.com.app

import android.os.Environment
import com.netease.nim.uikit.api.NimUIKit
import com.netease.nim.uikit.api.SessionHelper
import com.netease.nim.uikit.common.util.storage.ExternalStorage
import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.SDKOptions
import com.netease.nimlib.sdk.StatusBarNotificationConfig
import com.netease.nimlib.sdk.util.NIMUtil
import dagger.hilt.android.HiltAndroidApp
import www.wen.com.common.lib.app.BaseApplication


/**
 * @author WEN
 * @Description:
 * @date 2020/11/1 21:42
 */
@HiltAndroidApp
class App : BaseApplication(){

    override fun onCreate() {
        super.onCreate()
        initNIM()
    }

    private fun initNIM() {
        val sdkOptions = SDKOptions()
        sdkOptions.sdkStorageRootPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()+"/nim/"
        NIMClient.init(this, null, sdkOptions)
        if (NIMUtil.isMainProcess(this)) {
            NimUIKit.init(this)
            SessionHelper.init()
            NIMClient.updateStatusBarNotificationConfig(StatusBarNotificationConfig())
            NIMClient.toggleNotification(true)
        }
    }
}